<template>
  <div class="personal">
    <div class="user">
      <div class="info">
        <img src="" alt="" />
        <div class="user-name">测试姓名权</div>
      </div>
      <div
        class="item"
        v-for="(item, index) in userList"
        :key="index"
        @click="listFn(index)"
        :style="{ borderLeft: item.active ? '4px solid #4a90e2' : '' }"
      >
        <div class="item-img">
          <img :src="item.active ? item.icon2 : item.icon1" alt="" />
        </div>
        <div class="item-title">
          {{ item.title }}
        </div>
      </div>
    </div>
    <div class="user-content">
      <!-- <component :is="tempTitle" /> -->
      <account v-if="tempTitle == 'account'"></account>
      <equipment v-if="tempTitle == 'equipment'"></equipment>
      <vip v-if="tempTitle == 'vip'"></vip>
      <news v-if="tempTitle == 'news'"></news>
      <invoice v-if="tempTitle == 'invoice'"></invoice>
    </div>
  </div>
</template>
<script setup>
import { reactive, toRefs, ref } from "vue";
import img1 from "@/assets/user/1.png";
import img11 from "@/assets/user/1-1.png";
import img2 from "@/assets/user/2.png";
import img22 from "@/assets/user/2-2.png";
import img3 from "@/assets/user/3.png";
import img33 from "@/assets/user/3-3.png";
import img4 from "@/assets/user/4.png";
import img44 from "@/assets/user/4-4.png";
import img5 from "@/assets/user/5.png";
import img55 from "@/assets/user/5-5.png";
import account from "../../components/user/account.vue";
import equipment from "../../components/user/equipment.vue";
import vip from "../../components/user/vip.vue";
import news from "../../components/user/news.vue";
import invoice from "../../components/user/invoice.vue";
let data = reactive({
  userList: [
    {
      title: "账户信息",
      icon1: img1,
      icon2: img11,
      active: true,
      temp: "account",
    },
    { title: "设备绑定", icon1: img2, icon2: img22, temp: "equipment" },
    { title: "已购会员", icon1: img3, icon2: img33, temp: "vip" },
    { title: "系统消息", icon1: img4, icon2: img44, temp: "news" },
    { title: "发票申请", icon1: img5, icon2: img55, temp: "invoice" },
  ],
});
let { userList } = toRefs(data);
let tempTitle = ref("account");
function listFn(key) {
  userList.value.forEach((item, index) => {
    if (index == key) {
      item.active = true;
      tempTitle.value = item.temp;
    } else {
      item.active = false;
    }
  });
}
</script>

<style lang="less">
.personal {
  width: 1200px;
  margin: 0 auto;
  padding: 20px;
  height: 100%;
  display: flex;
  align-items: flex-start;
  .user {
    width: 240px;
    text-align: center;
    background: #fff;
    border-radius: 5px;
    padding: 10px 0;
    .info {
      border-bottom: 1px solid #f0f0f0;
      img {
        width: 80px;
        height: 80px;
      }
      .user-name {
        font-family: MicrosoftYaHei;
        font-size: 14px;
        color: #666;
        letter-spacing: 0;
        margin-bottom: 10px;
      }
    }
    .item {
      height: 65px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-bottom: 1px solid #f0f0f0;
      cursor: pointer;
      .item-img {
        width: 30px;
        height: 30px;
        margin-right: 20px;
        img {
          width: 100%;
          height: 100%;
        }
      }
    }
  }
  .user-content {
    min-height: 569px;
    background: #fff;
    border-radius: 5px;
    position: relative;
    padding-top: 30px;
    width: 926px;
    margin-left: 20px;
    padding: 30px;
  }
}
</style>
